package com.baoyi.adapter;

public class Page {
	private int totalRows;
	private int pageSize;
	private int currentPage;
	private int totalPages;
	public void config() {
		totalPages = totalRows / pageSize;
		if (totalRows % pageSize > 0) {
			totalPages++;
		}
		if (currentPage < 1) {
			currentPage = 1;
		}
		if (currentPage > totalPages) {
			currentPage = totalPages;
		}
	}

	public int getTotalRows() {
		return totalRows;
	}
	public void setTotalRows(int totalRows) {
		this.totalRows = totalRows;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getTotalPages() {
		return totalPages;
	}
	public int getStartRow() {
		return 0;
	}
	public int getEndRow() {
		int curzie=pageSize*currentPage;
		if (curzie > totalRows) {
			return totalRows;
		} else {
			return curzie;
		}

	}
	public Page() {
		currentPage = 0;
	}

}
